{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "651de65b-8403-44bb-a194-bfdd9018d760",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "#from vk_download import main\n",
    "#import scipy.sparse as sprs\n",
    "import time\n",
    "from tqdm.auto import tqdm\n",
    "import os\n",
    "import random\n",
    "import datetime\n",
    "#from threading import Thread\n",
    "#from multiprocessing import Process\n",
    "import numpy as np\n",
    "from scipy.sparse import csr_matrix, lil_matrix, csc_matrix\n",
    "#import scipy.sparse as sprs\n",
    "#from collections import OrderedDict\n",
    "#import shutil\n",
    "import matplotlib.pyplot as plt\n",
    "#import seaborn as sns\n",
    "import networkx as nx\n",
    "from IPython.display import clear_output\n",
    "#from statsmodels.stats.proportion import proportion_confint\n",
    "#import statsmodels.api as sm\n",
    "#from scipy.optimize import minimize\n",
    "import matplotlib as mpl\n",
    "import copy\n",
    "\n",
    "from Model_4 import ModelRealization\n",
    "from Support import SaveExperiment, LoadExperiment, LoadExperiments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fca02372-caf7-41a8-add0-8f87f03941a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "\n",
    "#------------------------------------ Define constant hyperparameters\n",
    "\n",
    "N = 100  # number of agents\n",
    "T = 1000 #1*N  # number of iterations (is equal to the number of agents)\n",
    "\n",
    "N_Bots = 0  # number of bots\n",
    "T_bots = 0  # \n",
    "\n",
    "m = 3  # number of opinions \n",
    "\n",
    "OpinionAlphabet = np.arange(m)  # possible opinions in the model (as in the SCARDO model) \n",
    "\n",
    "InitialOpinionDistribution = [0.15, 0.7, 0.15]\n",
    "\n",
    "ActivationProbabilitiesType = 'uniform'\n",
    "\n",
    "TransitionTable = [np.array([[1,      0,     0], \n",
    "                             [1,      0,     0], \n",
    "                             [1,      0,     0]]), \n",
    "                   \n",
    "                   np.array([[0.1,  0.9,   0], \n",
    "                             [0,    1,     0], \n",
    "                             [0,    0.9,   0.1]]), \n",
    "                   \n",
    "                   np.array([[0,    0,     1], \n",
    "                             [0,    0,     1], \n",
    "                             [0,    0,     1]])]\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "OrderOfActions = 'LikeFirst'\n",
    "#OrderOfActions = 'ReplyFirst'\n",
    "\n",
    "\n",
    "LikingProbabilities_Bots = np.array([[1,   0,   0], \n",
    "                                     [0,   0,   0], \n",
    "                                     [0,   0,   1]])\n",
    "\n",
    "\n",
    "ReplyWritingProbabilities_Bots = np.array([[1,  0,   1], \n",
    "                                           [0,  0,   0], \n",
    "                                           [1,  0,   1]])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "171b185e-e2ee-4696-8d8b-984b9bdd922b",
   "metadata": {},
   "source": [
    "# Alter $ \\alpha $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a7a09f6-727a-473d-8c18-551b8e488523",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Experiment number = 2, algorithm = Time, alpha = 0, beta = 0, gamma = 0, delta = 0\n"
     ]
    }
   ],
   "source": [
    "start = time.time()\n",
    "\n",
    "for experiment in range(100):\n",
    "    \n",
    "    for (Scale, Basis_Like, Basis_Reply) in [\n",
    "                                             (1/2, 0.15, 0.05), \n",
    "                                             (3, 0.15, 0.05), \n",
    "                                             (1/2, 0, 0),\n",
    "                                             (3, 0, 0),\n",
    "                                            ]:\n",
    "\n",
    "        #------------------------------------\n",
    "\n",
    "        ScaleFactor_Like = Basis_Like / (1 + Basis_Like)  # the total sum if the number of likes tend to infty is equal to 0.15\n",
    "        Ratio_Like = ScaleFactor_Like\n",
    "\n",
    "        ScaleFactor_Reply = Basis_Reply / (1 + Basis_Reply)  # the total sum if the number of likes tend to infty is equal to 0.025\n",
    "        Ratio_Reply = ScaleFactor_Reply\n",
    "\n",
    "\n",
    "        #------------------------------------ \n",
    "\n",
    "        beta = 0\n",
    "        gamma = 0\n",
    "        delta = 0\n",
    "\n",
    "    \n",
    "\n",
    "        for RankingAlgorithmType in [\n",
    "                                     'Time', \n",
    "                                     'RepliesCount', \n",
    "                                     'LikesCount',\n",
    "                                    ]:\n",
    "\n",
    "\n",
    "\n",
    "            for alpha in [0, 0.2, 0.4, 0.6, 0.8]: #np.arange(0, 1, 0.1):\n",
    "\n",
    "                print(f'Experiment number = {experiment+1}, algorithm = {RankingAlgorithmType}, alpha = {alpha}, beta = {beta}, gamma = {gamma}, delta = {delta}')\n",
    "                clear_output(wait=True)\n",
    "\n",
    "                                #------------------------------------ \n",
    "\n",
    "                LikingProbabilities = np.array([[0.3,   0,   0], \n",
    "                                                [0,     0,   0], \n",
    "                                                [round(0 + delta, 2),     0,   round(0.3 + gamma, 2)]])\n",
    "\n",
    "\n",
    "                ReplyWritingProbabilities = np.array([[0.1,            0,   0.05], \n",
    "                                                      [0,              0,   0], \n",
    "                                                      [round(0.05 + alpha, 2),   0,   round(0.1 + beta, 2)]])\n",
    "\n",
    "                #------------------------------------ \n",
    "\n",
    "                Arguments = {}\n",
    "\n",
    "                Arguments['N'] = N\n",
    "                Arguments['T'] = T\n",
    "                Arguments['m'] = m\n",
    "\n",
    "                Arguments['OpinionAlphabet'] = OpinionAlphabet\n",
    "                Arguments['InitialOpinionDistribution'] = InitialOpinionDistribution\n",
    "                Arguments['ActivationProbabilitiesType'] = ActivationProbabilitiesType\n",
    "                Arguments['RankingAlgorithmType'] = RankingAlgorithmType\n",
    "                Arguments['Scale'] = Scale  #!!\n",
    "                #Arguments['N_Comments_Display'] = N_Comments_Display  #!!\n",
    "                Arguments['OrderOfActions'] = OrderOfActions\n",
    "\n",
    "                Arguments['TransitionTable'] = TransitionTable\n",
    "                Arguments['ReplyWritingProbabilities'] = ReplyWritingProbabilities\n",
    "                Arguments['LikingProbabilities'] = LikingProbabilities\n",
    "\n",
    "\n",
    "                Arguments['Basis_Like'] = Basis_Like\n",
    "                Arguments['Basis_Reply'] = Basis_Reply\n",
    "                Arguments['ScaleFactor_Like'] = ScaleFactor_Like  #!!\n",
    "                Arguments['Ratio_Like'] = Ratio_Like  #!!\n",
    "                Arguments['ScaleFactor_Reply'] = ScaleFactor_Reply  #!!\n",
    "                Arguments['Ratio_Reply'] = Ratio_Reply  #!!\n",
    "\n",
    "                Arguments['N_Bots'] = N_Bots\n",
    "                Arguments['T_bots'] = T_bots\n",
    "\n",
    "                Arguments['ReplyWritingProbabilities_Bots'] = ReplyWritingProbabilities_Bots\n",
    "                Arguments['LikingProbabilities_Bots'] = LikingProbabilities_Bots\n",
    "\n",
    "\n",
    "                #------------------------------------ Perform an experiment\n",
    "\n",
    "                Records = ModelRealization(Arguments)\n",
    "\n",
    "\n",
    "\n",
    "                #------------------------------------ Save the experiment's records\n",
    "\n",
    "                SaveExperiment(Arguments, Records) \n",
    "                \n",
    "end = time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e632392e-ac9a-421f-bd14-f5d65e6ead37",
   "metadata": {},
   "source": [
    "# Alter $\\beta$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7e79ab22-de8d-4cd9-a1a6-95a1412aeeae",
   "metadata": {},
   "outputs": [],
   "source": [
    "start = time.time()\n",
    "\n",
    "\n",
    "\n",
    "for experiment in range(100):\n",
    "    \n",
    "    for (Scale, Basis_Like, Basis_Reply) in [\n",
    "                                             (1/2, 0.15, 0.05), \n",
    "                                             (3, 0.15, 0.05), \n",
    "                                             (1/2, 0, 0),\n",
    "                                             (3, 0, 0),\n",
    "                                            ]:\n",
    "\n",
    "        #------------------------------------\n",
    "\n",
    "        ScaleFactor_Like = Basis_Like / (1 + Basis_Like)  # the total sum if the number of likes tend to infty is equal to 0.15\n",
    "        Ratio_Like = ScaleFactor_Like\n",
    "\n",
    "        ScaleFactor_Reply = Basis_Reply / (1 + Basis_Reply)  # the total sum if the number of likes tend to infty is equal to 0.025\n",
    "        Ratio_Reply = ScaleFactor_Reply\n",
    "\n",
    "\n",
    "        #------------------------------------ \n",
    "\n",
    "\n",
    "\n",
    "        alpha = 0\n",
    "        gamma = 0\n",
    "        delta = 0\n",
    "\n",
    "\n",
    "        for RankingAlgorithmType in [\n",
    "                                     'Time', \n",
    "                                     'RepliesCount', \n",
    "                                     'LikesCount',\n",
    "                                    ]:\n",
    "\n",
    "\n",
    "\n",
    "            for beta in [0.2, 0.4, 0.6, 0.8]:\n",
    "\n",
    "                print(f'Experiment number = {experiment+1}, algorithm = {RankingAlgorithmType}, alpha = {alpha}, beta = {beta}, gamma = {gamma}, delta = {delta}')\n",
    "                clear_output(wait=True)\n",
    "\n",
    "                                #------------------------------------ \n",
    "\n",
    "                LikingProbabilities = np.array([[0.3,   0,   0], \n",
    "                                                [0,     0,   0], \n",
    "                                                [round(0 + delta, 2),     0,   round(0.3 + gamma, 2)]])\n",
    "\n",
    "\n",
    "                ReplyWritingProbabilities = np.array([[0.1,            0,   0.05], \n",
    "                                                      [0,              0,   0], \n",
    "                                                      [round(0.05 + alpha, 2),   0,   round(0.1 + beta, 2)]])\n",
    "\n",
    "                #------------------------------------ \n",
    "\n",
    "                Arguments = {}\n",
    "\n",
    "                Arguments['N'] = N\n",
    "                Arguments['T'] = T\n",
    "                Arguments['m'] = m\n",
    "\n",
    "                Arguments['OpinionAlphabet'] = OpinionAlphabet\n",
    "                Arguments['InitialOpinionDistribution'] = InitialOpinionDistribution\n",
    "                Arguments['ActivationProbabilitiesType'] = ActivationProbabilitiesType\n",
    "                Arguments['RankingAlgorithmType'] = RankingAlgorithmType\n",
    "                Arguments['Scale'] = Scale  #!!\n",
    "                #Arguments['N_Comments_Display'] = N_Comments_Display  #!!\n",
    "                Arguments['OrderOfActions'] = OrderOfActions\n",
    "\n",
    "                Arguments['TransitionTable'] = TransitionTable\n",
    "                Arguments['ReplyWritingProbabilities'] = ReplyWritingProbabilities\n",
    "                Arguments['LikingProbabilities'] = LikingProbabilities\n",
    "\n",
    "\n",
    "                Arguments['Basis_Like'] = Basis_Like\n",
    "                Arguments['Basis_Reply'] = Basis_Reply\n",
    "                Arguments['ScaleFactor_Like'] = ScaleFactor_Like  #!!\n",
    "                Arguments['Ratio_Like'] = Ratio_Like  #!!\n",
    "                Arguments['ScaleFactor_Reply'] = ScaleFactor_Reply  #!!\n",
    "                Arguments['Ratio_Reply'] = Ratio_Reply  #!!\n",
    "\n",
    "                Arguments['N_Bots'] = N_Bots\n",
    "                Arguments['T_bots'] = T_bots\n",
    "\n",
    "                Arguments['ReplyWritingProbabilities_Bots'] = ReplyWritingProbabilities_Bots\n",
    "                Arguments['LikingProbabilities_Bots'] = LikingProbabilities_Bots\n",
    "\n",
    "\n",
    "                #------------------------------------ Perform an experiment\n",
    "\n",
    "                Records = ModelRealization(Arguments)\n",
    "\n",
    "\n",
    "\n",
    "                #------------------------------------ Save the experiment's records\n",
    "\n",
    "                SaveExperiment(Arguments, Records)\n",
    "                \n",
    "end = time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef042e88-88af-45b3-a4e9-b312a469512f",
   "metadata": {},
   "source": [
    "# Alter $ \\gamma $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1a5c6b3-a155-427a-b800-374e4c27e832",
   "metadata": {},
   "outputs": [],
   "source": [
    "start = time.time()\n",
    "\n",
    "for experiment in range(100):\n",
    "    \n",
    "    for (Scale, Basis_Like, Basis_Reply) in [\n",
    "                                             (1/2, 0.15, 0.05), \n",
    "                                             (3, 0.15, 0.05), \n",
    "                                             (1/2, 0, 0),\n",
    "                                             (3, 0, 0),\n",
    "                                            ]:\n",
    "\n",
    "        #------------------------------------\n",
    "\n",
    "        ScaleFactor_Like = Basis_Like / (1 + Basis_Like)  # the total sum if the number of likes tend to infty is equal to 0.15\n",
    "        Ratio_Like = ScaleFactor_Like\n",
    "\n",
    "        ScaleFactor_Reply = Basis_Reply / (1 + Basis_Reply)  # the total sum if the number of likes tend to infty is equal to 0.025\n",
    "        Ratio_Reply = ScaleFactor_Reply\n",
    "\n",
    "\n",
    "        #------------------------------------ \n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "        alpha = 0\n",
    "        beta = 0\n",
    "        delta = 0\n",
    "\n",
    "\n",
    "        for RankingAlgorithmType in [\n",
    "                                     'Time', \n",
    "                                     'RepliesCount', \n",
    "                                     'LikesCount',\n",
    "                                    ]:\n",
    "\n",
    "\n",
    "\n",
    "            for gamma in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]: #np.arange(0.1, 0.75, 0.1):\n",
    "\n",
    "                print(f'Experiment number = {experiment+1}, algorithm = {RankingAlgorithmType}, alpha = {alpha}, beta = {beta}, gamma = {gamma}, delta = {delta}')\n",
    "                clear_output(wait=True)\n",
    "\n",
    "                                #------------------------------------ \n",
    "\n",
    "                LikingProbabilities = np.array([[0.3,   0,   0], \n",
    "                                                [0,     0,   0], \n",
    "                                                [round(0 + delta, 2),     0,   round(0.3 + gamma, 2)]])\n",
    "\n",
    "\n",
    "                ReplyWritingProbabilities = np.array([[0.1,            0,   0.05], \n",
    "                                                      [0,              0,   0], \n",
    "                                                      [round(0.05 + alpha, 2),   0,   round(0.1 + beta, 2)]])\n",
    "\n",
    "                #------------------------------------ \n",
    "\n",
    "                Arguments = {}\n",
    "\n",
    "                Arguments['N'] = N\n",
    "                Arguments['T'] = T\n",
    "                Arguments['m'] = m\n",
    "\n",
    "                Arguments['OpinionAlphabet'] = OpinionAlphabet\n",
    "                Arguments['InitialOpinionDistribution'] = InitialOpinionDistribution\n",
    "                Arguments['ActivationProbabilitiesType'] = ActivationProbabilitiesType\n",
    "                Arguments['RankingAlgorithmType'] = RankingAlgorithmType\n",
    "                Arguments['Scale'] = Scale  #!!\n",
    "                #Arguments['N_Comments_Display'] = N_Comments_Display  #!!\n",
    "                Arguments['OrderOfActions'] = OrderOfActions\n",
    "\n",
    "                Arguments['TransitionTable'] = TransitionTable\n",
    "                Arguments['ReplyWritingProbabilities'] = ReplyWritingProbabilities\n",
    "                Arguments['LikingProbabilities'] = LikingProbabilities\n",
    "\n",
    "\n",
    "                Arguments['Basis_Like'] = Basis_Like\n",
    "                Arguments['Basis_Reply'] = Basis_Reply\n",
    "                Arguments['ScaleFactor_Like'] = ScaleFactor_Like  #!!\n",
    "                Arguments['Ratio_Like'] = Ratio_Like  #!!\n",
    "                Arguments['ScaleFactor_Reply'] = ScaleFactor_Reply  #!!\n",
    "                Arguments['Ratio_Reply'] = Ratio_Reply  #!!\n",
    "\n",
    "                Arguments['N_Bots'] = N_Bots\n",
    "                Arguments['T_bots'] = T_bots\n",
    "\n",
    "                Arguments['ReplyWritingProbabilities_Bots'] = ReplyWritingProbabilities_Bots\n",
    "                Arguments['LikingProbabilities_Bots'] = LikingProbabilities_Bots\n",
    "\n",
    "\n",
    "                #------------------------------------ Perform an experiment\n",
    "\n",
    "                Records = ModelRealization(Arguments)\n",
    "\n",
    "\n",
    "\n",
    "                #------------------------------------ Save the experiment's records\n",
    "\n",
    "                SaveExperiment(Arguments, Records)   \n",
    "                \n",
    "                \n",
    "end = time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "49ab744b-1d1f-4a46-b39f-410e10aa2e03",
   "metadata": {},
   "source": [
    "# Alter $ \\delta $ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b44aff72-60ba-4b3b-8773-a89b89922b3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "start = time.time()\n",
    "\n",
    "\n",
    "\n",
    "for experiment in range(100):\n",
    "    \n",
    "    for (Scale, Basis_Like, Basis_Reply) in [\n",
    "                                             (1/2, 0.15, 0.05), \n",
    "                                             (3, 0.15, 0.05), \n",
    "                                             (1/2, 0, 0),\n",
    "                                             (3, 0, 0),\n",
    "                                            ]:\n",
    "\n",
    "        #------------------------------------\n",
    "\n",
    "        ScaleFactor_Like = Basis_Like / (1 + Basis_Like)  # the total sum if the number of likes tend to infty is equal to 0.15\n",
    "        Ratio_Like = ScaleFactor_Like\n",
    "\n",
    "        ScaleFactor_Reply = Basis_Reply / (1 + Basis_Reply)  # the total sum if the number of likes tend to infty is equal to 0.025\n",
    "        Ratio_Reply = ScaleFactor_Reply\n",
    "\n",
    "\n",
    "        #------------------------------------ \n",
    "\n",
    "        alpha = 0\n",
    "        beta = 0\n",
    "        gamma = 0\n",
    "\n",
    "\n",
    "        for RankingAlgorithmType in [\n",
    "                                     'Time', \n",
    "                                     'RepliesCount', \n",
    "                                     'LikesCount',\n",
    "                                    ]:\n",
    "\n",
    "\n",
    "\n",
    "            for delta in [0.2, 0.4, 0.6, 0.8, 1]: #np.arange(0.2, 1.1, 0.1):\n",
    "\n",
    "                print(f'Experiment number = {experiment+1}, algorithm = {RankingAlgorithmType}, alpha = {alpha}, beta = {beta}, gamma = {gamma}, delta = {delta}')\n",
    "                clear_output(wait=True)\n",
    "\n",
    "                                #------------------------------------ \n",
    "\n",
    "                LikingProbabilities = np.array([[0.3,   0,   0], \n",
    "                                                [0,     0,   0], \n",
    "                                                [round(0 + delta, 2),     0,   round(0.3 + gamma, 2)]])\n",
    "\n",
    "\n",
    "                ReplyWritingProbabilities = np.array([[0.1,            0,   0.05], \n",
    "                                                      [0,              0,   0], \n",
    "                                                      [round(0.05 + alpha, 2),   0,   round(0.1 + beta, 2)]])\n",
    "\n",
    "                #------------------------------------ \n",
    "\n",
    "                Arguments = {}\n",
    "\n",
    "                Arguments['N'] = N\n",
    "                Arguments['T'] = T\n",
    "                Arguments['m'] = m\n",
    "\n",
    "                Arguments['OpinionAlphabet'] = OpinionAlphabet\n",
    "                Arguments['InitialOpinionDistribution'] = InitialOpinionDistribution\n",
    "                Arguments['ActivationProbabilitiesType'] = ActivationProbabilitiesType\n",
    "                Arguments['RankingAlgorithmType'] = RankingAlgorithmType\n",
    "                Arguments['Scale'] = Scale  #!!\n",
    "                #Arguments['N_Comments_Display'] = N_Comments_Display  #!!\n",
    "                Arguments['OrderOfActions'] = OrderOfActions\n",
    "\n",
    "                Arguments['TransitionTable'] = TransitionTable\n",
    "                Arguments['ReplyWritingProbabilities'] = ReplyWritingProbabilities\n",
    "                Arguments['LikingProbabilities'] = LikingProbabilities\n",
    "\n",
    "\n",
    "                Arguments['Basis_Like'] = Basis_Like\n",
    "                Arguments['Basis_Reply'] = Basis_Reply\n",
    "                Arguments['ScaleFactor_Like'] = ScaleFactor_Like  #!!\n",
    "                Arguments['Ratio_Like'] = Ratio_Like  #!!\n",
    "                Arguments['ScaleFactor_Reply'] = ScaleFactor_Reply  #!!\n",
    "                Arguments['Ratio_Reply'] = Ratio_Reply  #!!\n",
    "\n",
    "                Arguments['N_Bots'] = N_Bots\n",
    "                Arguments['T_bots'] = T_bots\n",
    "\n",
    "                Arguments['ReplyWritingProbabilities_Bots'] = ReplyWritingProbabilities_Bots\n",
    "                Arguments['LikingProbabilities_Bots'] = LikingProbabilities_Bots\n",
    "\n",
    "\n",
    "                #------------------------------------ Perform an experiment\n",
    "\n",
    "                Records = ModelRealization(Arguments)\n",
    "\n",
    "\n",
    "\n",
    "                #------------------------------------ Save the experiment's records\n",
    "\n",
    "                SaveExperiment(Arguments, Records)\n",
    "                \n",
    "                \n",
    "end = time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a973873-d991-47cd-b1d0-79509018e45e",
   "metadata": {},
   "source": [
    "# Alter $ \\omega $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da9fde1d-c7ce-47ad-9bc6-dbe35dc1307c",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "for experiment in range(100):\n",
    "    \n",
    "    for (Scale, Basis_Like, Basis_Reply) in [\n",
    "                                             (1/2, 0.15, 0.05), \n",
    "                                             (3, 0.15, 0.05), \n",
    "                                             (1/2, 0, 0),\n",
    "                                             (3, 0, 0),\n",
    "                                            ]:\n",
    "\n",
    "        #------------------------------------\n",
    "\n",
    "        ScaleFactor_Like = Basis_Like / (1 + Basis_Like)  # the total sum if the number of likes tend to infty is equal to 0.15\n",
    "        Ratio_Like = ScaleFactor_Like\n",
    "\n",
    "        ScaleFactor_Reply = Basis_Reply / (1 + Basis_Reply)  # the total sum if the number of likes tend to infty is equal to 0.025\n",
    "        Ratio_Reply = ScaleFactor_Reply\n",
    "\n",
    "\n",
    "        #------------------------------------ \n",
    "\n",
    "        for RankingAlgorithmType in [\n",
    "                                     'Time', \n",
    "                                     'RepliesCount', \n",
    "                                     'LikesCount',\n",
    "                                    ]:\n",
    "\n",
    "\n",
    "\n",
    "            for omega in [0.1, 0.2, 0.3, 0.4, 0.5]:\n",
    "\n",
    "                print(f'Experiment number = {experiment+1}, algorithm = {RankingAlgorithmType}, omega = {omega}')\n",
    "                clear_output(wait=True)\n",
    "\n",
    "                #------------------------------------ \n",
    "\n",
    "                TransitionTable = [np.array([[1,      0,     0], \n",
    "                                             [1,      0,     0], \n",
    "                                             [1,      0,     0]]), \n",
    "\n",
    "                                   np.array([[0.1,  0.9,   0], \n",
    "                                             [0,    1,     0], \n",
    "                                             [0,    round(0.9 - omega, 2),   round(0.1 + omega, 2)]]), \n",
    "\n",
    "                                   np.array([[0,    0,     1], \n",
    "                                             [0,    0,     1], \n",
    "                                             [0,    0,     1]])]\n",
    "\n",
    "                #------------------------------------ \n",
    "\n",
    "                Arguments = {}\n",
    "\n",
    "                Arguments['N'] = N\n",
    "                Arguments['T'] = T\n",
    "                Arguments['m'] = m\n",
    "\n",
    "                Arguments['OpinionAlphabet'] = OpinionAlphabet\n",
    "                Arguments['InitialOpinionDistribution'] = InitialOpinionDistribution\n",
    "                Arguments['ActivationProbabilitiesType'] = ActivationProbabilitiesType\n",
    "                Arguments['RankingAlgorithmType'] = RankingAlgorithmType\n",
    "                Arguments['Scale'] = Scale  #!!\n",
    "                #Arguments['N_Comments_Display'] = N_Comments_Display  #!!\n",
    "                Arguments['OrderOfActions'] = OrderOfActions\n",
    "\n",
    "                Arguments['TransitionTable'] = TransitionTable\n",
    "                Arguments['ReplyWritingProbabilities'] = ReplyWritingProbabilities\n",
    "                Arguments['LikingProbabilities'] = LikingProbabilities\n",
    "\n",
    "\n",
    "                Arguments['Basis_Like'] = Basis_Like\n",
    "                Arguments['Basis_Reply'] = Basis_Reply\n",
    "                Arguments['ScaleFactor_Like'] = ScaleFactor_Like  #!!\n",
    "                Arguments['Ratio_Like'] = Ratio_Like  #!!\n",
    "                Arguments['ScaleFactor_Reply'] = ScaleFactor_Reply  #!!\n",
    "                Arguments['Ratio_Reply'] = Ratio_Reply  #!!\n",
    "\n",
    "                Arguments['N_Bots'] = N_Bots\n",
    "                Arguments['T_bots'] = T_bots\n",
    "\n",
    "                Arguments['ReplyWritingProbabilities_Bots'] = ReplyWritingProbabilities_Bots\n",
    "                Arguments['LikingProbabilities_Bots'] = LikingProbabilities_Bots\n",
    "\n",
    "\n",
    "                #------------------------------------ Perform an experiment\n",
    "\n",
    "                Records = ModelRealization(Arguments)\n",
    "\n",
    "\n",
    "\n",
    "                #------------------------------------ Save the experiment's records\n",
    "\n",
    "                SaveExperiment(Arguments, Records)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "07331a59-aa12-4b2d-9a3a-f002b206734f",
   "metadata": {},
   "source": [
    "# Alter the initial opinion distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "550b18a0-3a24-4789-8450-dfda35a9d19e",
   "metadata": {},
   "outputs": [],
   "source": [
    "for experiment in range(100):\n",
    "    \n",
    "    for (Scale, Basis_Like, Basis_Reply) in [\n",
    "                                             (1/2, 0.15, 0.05), \n",
    "                                             (3, 0.15, 0.05), \n",
    "                                             #(1/2, 0, 0),\n",
    "                                             (3, 0, 0),\n",
    "                                            ]:\n",
    "\n",
    "        #------------------------------------\n",
    "\n",
    "        ScaleFactor_Like = Basis_Like / (1 + Basis_Like)  # the total sum if the number of likes tend to infty is equal to 0.15\n",
    "        Ratio_Like = ScaleFactor_Like\n",
    "\n",
    "        ScaleFactor_Reply = Basis_Reply / (1 + Basis_Reply)  # the total sum if the number of likes tend to infty is equal to 0.025\n",
    "        Ratio_Reply = ScaleFactor_Reply\n",
    "\n",
    "        for RankingAlgorithmType in [\n",
    "                                     'Time', \n",
    "                                     'RepliesCount', \n",
    "                                     'LikesCount',\n",
    "                                    ]:\n",
    "            (N_Bots, T_bots) = (0, 0)\n",
    "            \n",
    "\n",
    "\n",
    "            for InitialOpinionDistribution in [\n",
    "                                               [0.15, 0.6, 0.25], \n",
    "                                               [0.15, 0.5, 0.35], \n",
    "                                               [0.15, 0.4, 0.45], \n",
    "                                               [0.15, 0.3, 0.55], \n",
    "                                               [0.15, 0.2, 0.65]\n",
    "                                              ]:\n",
    "\n",
    "\n",
    "                print(f'Experiment number = {experiment+1}, algorithm = {RankingAlgorithmType}, N_Bots={N_Bots}, T_bots={T_bots}')\n",
    "\n",
    "                clear_output(wait=True)\n",
    "\n",
    "                Arguments = {}\n",
    "\n",
    "                Arguments['N'] = N\n",
    "                Arguments['T'] = T\n",
    "                Arguments['m'] = m\n",
    "\n",
    "                Arguments['OpinionAlphabet'] = OpinionAlphabet\n",
    "                Arguments['InitialOpinionDistribution'] = InitialOpinionDistribution\n",
    "                Arguments['ActivationProbabilitiesType'] = ActivationProbabilitiesType\n",
    "                Arguments['RankingAlgorithmType'] = RankingAlgorithmType\n",
    "                Arguments['Scale'] = Scale  #!!\n",
    "                #Arguments['N_Comments_Display'] = N_Comments_Display  #!!\n",
    "                Arguments['OrderOfActions'] = OrderOfActions\n",
    "\n",
    "                Arguments['TransitionTable'] = TransitionTable\n",
    "                Arguments['ReplyWritingProbabilities'] = ReplyWritingProbabilities\n",
    "                Arguments['LikingProbabilities'] = LikingProbabilities\n",
    "\n",
    "\n",
    "                Arguments['Basis_Like'] = Basis_Like\n",
    "                Arguments['Basis_Reply'] = Basis_Reply\n",
    "                Arguments['ScaleFactor_Like'] = ScaleFactor_Like  #!!\n",
    "                Arguments['Ratio_Like'] = Ratio_Like  #!!\n",
    "                Arguments['ScaleFactor_Reply'] = ScaleFactor_Reply  #!!\n",
    "                Arguments['Ratio_Reply'] = Ratio_Reply  #!!\n",
    "\n",
    "                Arguments['N_Bots'] = N_Bots\n",
    "                Arguments['T_bots'] = T_bots\n",
    "\n",
    "                Arguments['ReplyWritingProbabilities_Bots'] = ReplyWritingProbabilities_Bots\n",
    "                Arguments['LikingProbabilities_Bots'] = LikingProbabilities_Bots\n",
    "\n",
    "\n",
    "                #------------------------------------ Perform an experiment\n",
    "\n",
    "                Records = ModelRealization(Arguments)\n",
    "\n",
    "\n",
    "\n",
    "                #------------------------------------ Save the experiment's records\n",
    "\n",
    "                SaveExperiment(Arguments, Records)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
